package test7;

import java.util.*;
import java.util.stream.Collectors;

public class Demo11 {
    static HashMap<Integer, Integer> table = new HashMap<>();
    public static void main(String[] args) {
        table.put(0,(int) '0');
        table.put(1,(int) '1');
        table.put(2,(int) '2');
        table.put(3,(int) '3');
        table.put(4,(int) '4');
        table.put(5,(int) '5');
        table.put(6,(int) '6');
        table.put(7,(int) '7');
        table.put(8,(int) '8');
        table.put(9,(int) '9');
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 100; i <= 999; i++) {
            for (int j = 'A'; j <= 'Z'; j++) {
                int x = i % 10;
                int y = i / 10 % 10;
                int z = i / 100;
                map.put(i + "" + (char) j, table.get(x) + table.get(y) + table.get(z) + j);
            }
        }

        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        List<Map.Entry<String, Integer>> collect = entries.stream().sorted(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                return o1.getValue() - o2.getValue();
            }
        }).collect(Collectors.toList());

        for (int i = 0; i < collect.size(); i++) {
            System.out.println(collect.get(i).getKey());
        }

    }
}
